"""Main Controller"""
from arkivo.lib.base import BaseController
from tg import expose, flash
from pylons.i18n import ugettext as _
#from tg import redirect, validate
#from arkivo.model import DBSession

# Supports the copyright date in the footer template
from datetime import datetime

from arkivo import model
from arkivo.controllers.archive import ArchiveController

from arkivo.model import metadata

class RootController(BaseController):

    archive = ArchiveController()
    # Need a way of securing DBMechanic
    #dbmechanic = DBMechanic(SAProvider(metadata), '/dbmechanic')

    @expose('arkivo.templates.index')
    def index(self, *args, **kw):
        live_channels = model.Channel.query.filter_by(enabled=True)
        old_channels = model.Channel.query.filter_by(enabled=False)
        return dict(live_channels=live_channels,
                    old_channels=old_channels)

